<?php
ifi!$_GET['cmd'])
{
	SQLvalidate($_GET['gid']);

	$db = new dbquery;
	$db->query("SELECT * FROM $conf[prefix_groups]groups WHERE type=2 || type=3 ORDER by name_$_SESSION[lang_short] ASC") or $db->err(__FILE__, __LINE__);

	if(!$_GET['gid']) {
		$contact_query='gid=3';
		while($d=$db->fetch_object())
			$contact_query.=' || gid='.$d->id.'';
	} else {
		$contact_query='gid='.$_GET['gid'];	
	}

	$db->query("SELECT * FROM $conf[prefix_users]users WHERE $contact_query ORDER by gid") or $db->err(__FILE__, __LINE__);

	if($db->num_rows()==0) {
		redirect ($_SESSION['redirect_1']);
		exit;
	}

	while($d=$db->fetch_object()) {
		if($_GET['id']==$d->id)
			$selected="SELECTED";
		else
			$selected='';

		$admin_options.='<option value="'.$d->id.'" '.$selected.'>'.$d->name.' '.$d->surname.' ['.$d->login.']</option>';
	}

	if(is_numeric($_GET['file'])) {
		$text=$_GET['what']." \n\n";
		$mail='guest@'.$_SERVER['HTTP_HOST'];
	}

	$content=string_template(read_file('contact_form.php'), array('options'=>$admin_options, 'mail'=>$mail, 'text'=>$text));
}
//

//generating $content for body.php
$content=string_template(read_file('middle.php'), array('theme_path' => $GLOBALS['theme_path'], 'content' => $content, 'description' => $lang['contact_description']));

//generating menus (what, template)
$menu_left=menu('left', 'left');
$menu_right=menu('right', 'right');
$menu_top=menu('top', 'top');
//

//site_generation_time
$GLOBALS['time_end'] = microtime(1);
$site_generation_time=abs(round($GLOBALS['time_end']-$GLOBALS['time_start'], 3));
//

//creating template
$tpl=new tpl;
//header
$tpl->create('header.php', array('title' => $GLOBALS['lang']['global']['site_title'], 'description' => $GLOBALS['lang']['global']['site_description'], 'keywords' => $GLOBALS['lang']['global']['site_keywords'], 'theme_path'=>$GLOBALS['theme_path'], 'menu_top' => $menu_top));
//body
$tpl->create('body.php', array('theme_path' => $GLOBALS['theme_path'], 'menu_top' => $menu_top, 'menu_left' => $menu_left, 'menu_right' => $menu_right, 'content' => $content));
//footer
$tpl->create('footer.php', array('site_generation_time' => string_template($GLOBALS['lang']['global']['site_generation_time'], array('site_generation_time'=>$site_generation_time, 'queries'=>$db->query_count())), 'theme_path'=>$GLOBALS['theme_path'], 'copyright' => $GLOBALS['lang']['global']['site_copyright'], 'queries'=>$db->query_count()));
//parse
$tpl->parse();

?>
